package eteam.aps.controller;

import eteam.aps.common.R;
import eteam.aps.common.exceptions.BusinessException;
import eteam.aps.common.helper.Helper;
import eteam.aps.model.vo.moco_rders.MocoRdersDisplayVo;
import eteam.aps.model.vo.moco_rders.MocoRedersShowVo;
import eteam.aps.service.MocoRdersService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 工单表 控制层
 *
 * @author LiuLei
 */
@Api(tags = "工单表")
@RestController
@RequestMapping("/mrc")
public class MocoRdersController {

    @Autowired
    private MocoRdersService mocoRdersService;

    @PostMapping("/mcpn/{mocCode}")
    @ApiOperation("根据工单代号查询工单序号信息")
    @ApiImplicitParam(name = "mocCode", value = "工单代号")
    public R<MocoRedersShowVo> getByMcPn(@PathVariable String mocCode) throws Exception {
        if (Helper.isEmpty(mocCode)) throw new BusinessException(HttpStatus.BAD_REQUEST, "工单代号不能为空");
        return R.success(mocoRdersService.getByMcPn(mocCode));
    }

    @PostMapping("/mc/{mocCode}")
    @ApiOperation("根据工单代号查询")
    @ApiImplicitParam(name = "mocCode", value = "工单代号")
    public R<List<MocoRdersDisplayVo>> getByMc(@PathVariable String mocCode) throws Exception {
        if (Helper.isEmpty(mocCode)) throw new BusinessException(HttpStatus.BAD_REQUEST, "工单代号不能为空");
        return R.success(mocoRdersService.getByMc(mocCode));
    }

}
